package com.ftwj.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ftwj.entity.SchoolPlaceInfo;
import com.ftwj.entity.SchoolRoomSeatInfo;
import com.ftwj.mapper.SchoolPlaceMapper;
import com.ftwj.mapper.SchoolRoomSeatMapper;
import com.ftwj.mapper.UserAppointmentInfoMapper;
import org.springframework.beans.factory.annotation.Autowired;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;

@Service
public class SchoolPlaceService {
    @Autowired
    private SchoolPlaceMapper schoolPlaceMapper;



    public IPage<Map<String ,Object>>selectSchoolPlaceInfoByName(Page<Object> page,
                                                                 String name
                                                                 ){
        IPage<Map<String, Object>> SchoolPlaceList = schoolPlaceMapper.selectSchoolPlaceInfoByName(page,name);
        return SchoolPlaceList;
    }

    public IPage<Map<String ,Object>>selectSchoolPlaceInfoAll(Page<Object> page
    ){
        IPage<Map<String, Object>> SchoolPlaceList = schoolPlaceMapper.selectSchoolPlaceInfoAll(page);
        return SchoolPlaceList;
    }

    public int insertSchoolPlaceInfo(SchoolPlaceInfo schoolPlaceInfo) {
        if (schoolPlaceInfo.getId() == null || schoolPlaceInfo.getId().isEmpty()) {
            String newId = UUID.randomUUID().toString();  // 生成UUID
            schoolPlaceInfo.setId(newId);
            System.out.println("Generated UUID: " + newId);  // 输出生成的UUID
        } else {
            System.out.println("Using provided ID: " + schoolPlaceInfo.getId());  // 输出提供的ID
        }
        return schoolPlaceMapper.insertSchoolPlaceInfo(schoolPlaceInfo);
    }



    public int updateSchoolPlaceInfo(SchoolPlaceInfo schoolPlaceInfo){
        return schoolPlaceMapper.updateSchoolPlaceInfo(schoolPlaceInfo);
    }

    public int updateSchoolPlaceOpenState(SchoolPlaceInfo schoolPlaceInfo){
        return schoolPlaceMapper.updateSchoolPlaceOpenState(schoolPlaceInfo);
    }

    public int deleteSchoolPlaceInfoById(String id){
        return schoolPlaceMapper.deleteSchoolPlaceInfoById(id);
    }

}
